﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="ErrorController.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：ErrorController.cs
// 创建时间：2015-03-11 9:45
// 修改时间：2015-03-11 9:45
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

using System;
using System.Web.Mvc;

namespace Ema.Controllers
{
    /// <summary>
    /// The error controller.
    /// </summary>
    public class ErrorController : BaseController
    {
        #region Public Methods and Operators

        /// <summary>
        /// 异常处理
        /// </summary>
        /// <param name="ex">
        /// The ex.
        /// </param>
        /// <param name="controller">
        /// The controller.
        /// </param>
        /// <param name="action">
        /// The action.
        /// </param>
        /// <param name="isjson">
        /// The isjson.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        [NonAction]
        public ActionResult Msg(Exception ex, object controller, object action, bool isjson)
        {
            if (controller != null)
            {
                // 控制器
            }

            if (action != null)
            {
                // 行为
            }

            if (isjson)
            {
                return this.GetJsonDb(ex.Message);
            }
            else
            {
                return RedirectToAction("Sorry", "Error");
            }

        }

        #endregion

        /// <summary>
        /// 错误页
        /// </summary>
        /// <returns></returns>
        public ActionResult Sorry(string ms = "404")
        {
            return this.PartialView(ms);
        }

        /// <summary>
        /// 错误页
        /// </summary>
        /// <param name="ms">
        /// The ex.
        /// </param>
        /// <returns>
        /// </returns>
        public ActionResult SorryJson(string ms)
        {
            return this.GetJsonDb(ms);
        }
    }
}